Skip to content

Conversation

@kmahar
Copy link
Contributor

@kmahar kmahar commented Apr 21, 2020

@mbroadst I'm not sure if you want me to keep including you on these, LMK.

This PR switches ReadPreference over to the "create a temporary libmongoc equivalent, use it to execute a closure, and then clean it up" approach we follow for ReadConcern, WriteConcern, MongoDatabase, and MongoCollection.

We had existing tests regarding ReadConcern and WriteConcern that verified these got set correctly on mongoc clients, dbs, and collections. I think we skipped these for ReadPreference at the time because it was just wrapping a mongoc_read_prefs_t so there was no need to test out the temporary creation of the libmongoc type.

I have now added similar tests for ReadPreference. As part of that I also moved libmongoc-dependent helper methods for getting the ReadConcern/WriteConcern on a temporary db/collection into the driver itself. This allowed me to remove the CLibMongoC dependency from MongoSwiftTests 🎉Now we just need to remove it from BSONTests.

I also added some round trip testing between Swift and libmongoc types for all three of RC, WC, RP.

@kmahar kmahar requested review from mbroadst and patrickfreed April 21, 2020 23:18
@codecov-io
Copy link

codecov-io commented Apr 21, 2020

Codecov Report

Merging #456 into master will increase coverage by 0.19%.
The diff coverage is 92.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #456      +/-   ##
==========================================
+ Coverage   76.42%   76.62%   +0.19%     
==========================================
  Files         117      117              
  Lines       12935    12982      +47     
==========================================
+ Hits         9886     9947      +61     
+ Misses       3049     3035      -14     
Impacted Files Coverage Δ
Sources/MongoSwift/ConnectionPool.swift 47.22% <0.00%> (-0.45%) ⬇️
...goSwift/Operations/StartTransactionOperation.swift 34.21% <33.33%> (-0.93%) ⬇️
Sources/MongoSwift/Operations/FindOperation.swift 97.82% <75.00%> (ø)
...ces/MongoSwift/Operations/AggregateOperation.swift 97.50% <90.00%> (ø)
Sources/MongoSwift/ConnectionString.swift 82.00% <100.00%> (+0.18%) ⬆️
Sources/MongoSwift/MongoClient.swift 85.81% <100.00%> (+0.91%) ⬆️
Sources/MongoSwift/MongoCollection+BulkWrite.swift 85.97% <100.00%> (ø)
Sources/MongoSwift/MongoCollection.swift 98.38% <100.00%> (+4.50%) ⬆️
Sources/MongoSwift/MongoDatabase.swift 80.18% <100.00%> (+4.66%) ⬆️
...ongoSwift/Operations/CountDocumentsOperation.swift 100.00% <100.00%> (ø)
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b8a3726...59eb7f7. Read the comment docs.

@mbroadst mbroadst removed their request for review April 23, 2020 12:15
@kmahar kmahar requested a review from nbbeeken April 23, 2020 15:26
.target(name: "TestsCommon", dependencies: ["MongoSwift", "Nimble"]),
.testTarget(name: "BSONTests", dependencies: ["MongoSwift", "TestsCommon", "Nimble", "CLibMongoC"]),
.testTarget(name: "MongoSwiftTests", dependencies: ["MongoSwift", "TestsCommon", "Nimble", "NIO", "CLibMongoC"]),
.testTarget(name: "MongoSwiftTests", dependencies: ["MongoSwift", "TestsCommon", "Nimble", "NIO"]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉🎉🎉

@kmahar kmahar requested review from mbroadst and removed request for mbroadst April 23, 2020 17:22
@kmahar
Copy link
Contributor Author

kmahar commented Apr 23, 2020

whoops sorry i was trying to actually remove your name @mbroadst but i guess since you commented once already you are stuck on the list forever

Copy link
Contributor

@patrickfreed patrickfreed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, just a few minor comments

@kmahar kmahar requested a review from patrickfreed April 24, 2020 17:40
@kmahar kmahar merged commit 973acb2 into master Apr 24, 2020
@kmahar kmahar deleted the SWIFT-779/read-preference branch April 24, 2020 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants